<template>
  <div class="bottomScreen">
    <div class="entScreen">
      <div class="title">
        <img :src="leftIcon" alt="" />
        <span>报警状态</span>
        <img :src="rightIcon" alt="" />
      </div>
      <div class="content">
        <template v-if="dataList.length > 0">
          <vue-seamless-scroll
            :data="dataList"
            class="seamless-warp"
            :class-option="classOption"
          >
            <el-row :gutter="20" v-for="(item, index) in dataList" :key="index">
              <div class="listCon">
                <el-col :span="8">
                  <el-tooltip
                    effect="dark"
                    :content="item.spaceInfo ? item.spaceInfo.screenName : ''"
                    placement="top"
                  >
                    <div class="proName">
                      {{ item.spaceInfo ? item.spaceInfo.screenName : "" }}
                    </div>
                  </el-tooltip>
                  <div></div>
                </el-col>
                <el-col :span="4">
                  <div>
                    {{
                      item.deviceInfo
                        ? item.deviceInfo.name
                          ? item.deviceInfo.name
                          : "无设备"
                        : "无设备"
                    }}
                  </div>
                </el-col>
                <el-col :span="10">
                  <div>{{ item.appendReason }}</div>
                </el-col>
                <el-col :span="2">
                  <div>{{ item.status === 1 ? "已处理" : "未处理" }}</div>
                </el-col>
              </div>
            </el-row>
          </vue-seamless-scroll>
        </template>
        <template v-else>
          <div class="noData">暂无数据</div>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import leftIcon from "@/assets/img/leftIcon.png";
import rightIcon from "@/assets/img/rightIcon.png";
import vueSeamless from "vue-seamless-scroll";
import { alarmsList } from "@/api/enterpriserSre";
export default {
  components: {
    "vue-seamless-scroll": vueSeamless,
  },
  data() {
    return {
      leftIcon: leftIcon,
      rightIcon: rightIcon,
      dataList: [],
    };
  },
  computed: {
    spaceId() {
      return this.$store.getters.entSpaceId;
    },
    classOption() {
      return {
        singleHeight: 100,
        direction: 1,
        limitMoveNum: 1,
      };
    },
  },
  mounted() {
    this.alarmsList();
  },
  methods: {
    alarmsList() {
      let params = {
        d: {
          page: {
            p: 1,
            ps: 10,
          },
          filters: [
            {
              field: "entSpaceId",
              operator: "EQUALS",
              value: this.spaceId,
            },
            {
              field: "status",
              operator: "NE",
              value: 1,
            },
          ],
          sorts: [
            {
              field: "ct",
              isDesc: true,
            },
          ],
          fields: [
            {
              name: "spaceInfo",
            },
            {
              name: "deviceInfo",
            },
            {
              name: "disposeRecord",
            },
          ],
          c: [
            {
              key: "entSpaceId",
              value: this.spaceId,
            },
          ],
        },
      };
      alarmsList(params).then((res) => {
        this.dataList = res.result;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
* {
  font-size: 16px;
  color: #fff;
}
.bottomScreen {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  .content {
    width: 1000px;
  }
  .seamless-warp {
    height: 100px;
    overflow: hidden;
    .listCon {
      padding: 15px;
      .proName {
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
  .noData {
    padding: 30px 0;
    text-align: center;
    font-size: 16px;
  }
}
</style>